package org.fuxia.im.listeners;

import java.util.List;

import org.fuxia.im.common.ClientConst;
import org.fuxia.im.common.ClientContext;
import org.fuxia.im.core.entries.ECResponse;
import org.fuxia.im.core.utils.ObjectUtil;
import org.fuxia.im.gui.Main;

import com.alibaba.fastjson.JSONObject;

/**
 * 处理创建群组结果
 *
 */
public class GroupAddResultListener extends CommonListener {

	@SuppressWarnings("unchecked")
	@Override
	public void trigger(Object param) {
		super.trigger(param);
		ECResponse resp = (ECResponse) param;
		Object newChat = resp.get("new_group") ;
		if(newChat!=null) {
			JSONObject newChatJ = ObjectUtil.getObjectByJsonStr(newChat.toString(), JSONObject.class) ;
			ClientContext.getValue(ClientConst.GROUPS,List.class).add(newChatJ);
			ClientContext.getValue(ClientConst.MAIN_WINDOW, Main.class).addNode(newChatJ);
		}
	}

	
}
